using System;
using System.Text.RegularExpressions;
using Mono.Cecil;

namespace LoggingMagic.Extensions
{
    internal static class FullNameExtensions
    {
        private static readonly Regex _signatureRegex = new Regex(@"::(?<signature>.*)$");
        public static string MethodSignature(this string fullName)
        {
            return _signatureRegex.Match(fullName).Groups["signature"].Value;
        }


        private static readonly Regex _nameRegex = new Regex(@"\.(?<class>[^\.]*?)::");
        public static string MethodName(this MethodDefinition method)
        {
            var className = _nameRegex.Match(method.FullName).Groups["class"].Value;

            return String.Format("{0}.{1}", className, method.Name);
        }
    }
}